#include <iostream>
#include <string>
#include <vector>

using namespace std;
// 两个维度的01背包
int test(vector<string>& strs, int m, int n) {
  vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
  int len = strs.size();
  int i, j, one_num, zero_num;
  for (auto& temp_str : strs) {
    one_num = 0;
    zero_num = 0;
    for (auto& temp_char : temp_str) {
      if (temp_char == '0')
        zero_num++;
      else
        one_num++;
    }
    for (i = m; i >= zero_num; i--) {
      for (j = n; j >= one_num; j--) {
        dp[i][j] = max(dp[i - zero_num][j - one_num] + 1, dp[i][j]);
      }
    }
  }
  return dp[m][n];
}
int main() {
  vector<string> strs{"10", "0001", "111001", "1", "0"};
  int m = 5, n = 3;
  cout << test(strs, m, n) << endl;
  return 0;
}